<template>
  <div class="search">
    <main-header></main-header>
    <div class="wrap">
      <search-input></search-input>
      <ul id="classify">
        <li class="f-fs-fs" v-for="(classify, ind) in classifys" :key="ind">
          <div>
            <b>{{ classify.text + ":" }}</b>
          </div>
          <span
            :class="opt.id == allCurrIds[classify.name] ? 'active' : ''"
            v-for="(opt, ind) in classify.opts"
            :key="ind"
            @click="changeActive(classify.name, opt.id)"
            >{{ opt.text }}</span
          >
        </li>
      </ul>
      <div class="hint f-sb-c">
        <div>已为您找到&nbsp;&nbsp;<b>111</b>&nbsp;&nbsp;条结果。</div>
        <el-select
          v-model="orderVal"
          style="width: 110px"
          size="mini"
          placeholder="排序方式"
          @change="getOrderVal"
        >
          <el-option
            v-for="item in orderType"
            :key="item.id"
            :label="item.type"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </div>
      <div id="show" class="f-sb-fs">
        <div class="section">
          <line-sell v-for="(item, ind) in 10" :key="ind"></line-sell>
          <div id="page" class="f-c-c">
            <el-pagination
              @size-change="pageSizeChange"
              @current-change="currPageChange"
              :current-page.sync="currPage"
              :page-size="pageSize"
              layout="prev, pager, next, jumper"
              :total="total"
              background
            >
            </el-pagination>
          </div>
        </div>
        <div class="side">
          <rank-list></rank-list>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import MainHeader from "../components/section/MainHeader.vue";
import SearchInput from "../components/side/SearchInput.vue";
import LineSell from "../components/side/LineSell.vue";
import QuickTab from "../components/section/QuickTab.vue";
import RankList from '../components/section/RankList.vue';
export default {
  name: "search",
  components: {
    MainHeader,
    SearchInput,
    LineSell,
    QuickTab,
    RankList,
  },
  data() {
    return {
      orderVal: 1,
      currPage: 1,
      pageSize: 10,
      total: 104,
      allCurrIds: {},
    };
  },
  computed: {
    classifys() {
      return this.$store.state.opts.searchClassifys;
    },
    orderType() {
      return this.$store.state.opts.orderType;
    },
  },
  methods: {
    pageSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    currPageChange(val) {
      console.log(`当前页: ${val}`);
    },
    getOrderVal(val) {
      console.log(val);
    },
    changeActive(key, optId) {
      this.$set(this.allCurrIds, key, optId);
      this.$forceUpdate();
    },
  },
  mounted() {
    this.classifys.forEach((item) => {
      this.allCurrIds[item.name] = 0;
    });
    console.log(this.allCurrIds);
  },
};
</script>
<style lang="scss" scoped>
.wrap{
  margin-bottom: 30px;
}
#search-box {
  height: 100px;
}
#classify {
  padding: 10px;
  margin-bottom: 10px;
  box-sizing: border-box;
  border-radius: $border-radius-base;
  border: 1px solid $theme-color;
  li {
    padding: 5px 10px;

    &:hover {
      background: $background-color-base;
    }
    &:not(:last-child) {
      border-bottom: 1px solid $border-radius-base;
    }
  }
  div {
    width: 80px;
    margin-right: 20px;
    text-align-last: justify;
  }
  .active {
    color: #ffffff;
    background: $theme-color;
  }
  span {
    cursor: pointer;
    display: inline-block;
    line-height: 26px;
    color: $color-text-regular;
    padding: 0 5px;
    border: 1px solid transparent;
    border-radius: $border-radius-base;
    &:hover {
      color: #ffffff;
      background: $theme-color;
    }
    &:not(:last-child) {
      margin-right: 20px;
    }
  }
}
.hint {
  color: #ffffff;
  font-size: 16px;
  padding: 0 10px;
  margin: 15px 0 20px;
  border-radius: $border-radius-base;
  line-height: 40px;
  background: $theme-color;
  b {
    font-size: 20px;
  }
}
#page {
  padding: 20px 0;
}
</style>